<?php $_SESSION['History']['Pre']= array('controller'=>'bulletins', 'action'=>'view', $data['Post']['id'])?>
<?php $paginator->options(array('url' => $this->passedArgs));?>
<table>
	<tr>
		<td width="25%"><?php echo $data['User']['username']?></td>
		<td><?php echo date('Y-m-d H:i:s', $data['Post']['ptime'])?></td>
	</tr>
	<tr>
		<td width="25%">
			<?php if($session->read('Auth.User.group_id')==1 || $session->read('Auth.User.id')==$data['Post']['user_id']):?>
			<?php echo $html->link('編', array('controller'=>'posts', 'action'=>'edit', $data['Post']['id']))?>
			|
			<?php echo $html->link('刪', 
				array(
					'controller'=>'posts', 
					'action'=>'delete', 
					$data['Post']['id']
				),
				array(),
				'確定要刪除嗎？'
				
			)?>
			<?php endif?>
		</td>
		<td class="post_content">
			<table>
			<tr><td>標題  ： <?php echo $data['Post']['title']?></td></tr>
			<tr><td><?php echo nl2br($data['Post']['content'])?></td></tr>
			</table>
		</td>
	</tr>
</table>

<?php if($session->read('Auth.User')!=array()):?>
	<table><tr><td>
	<?php echo $form->create('Repost')?>
	<?php echo $form->textarea('content')?>
	<?php echo $form->hidden('post_id', array('value'=>$data['Post']['id']))?>
	<?php echo $form->hidden('user_id', array('value'=>$session->read('Auth.User.id')))?>
	<?php echo $form->end('新增回應');?>
	</td></tr></table>
<?php else:?>
	<table><tr><td>
	<?php echo $html->link('登入', array('controller'=>'users', 'action'=>'login'))?>
	後才可以發表文章
	</td></tr></table>
<?php endif?>

<?php if(!empty($reposts)):?>
<table>
	<tr><th colspan=2><?php echo $paginator->sort('回應時間排序', 'Repost.id')?></th></tr>
	<?php foreach($reposts as $repost):?>
	<tr>
		<td width="25%"><?php echo $repost['Repost']['username']?></td>
		<td><?php echo date('Y-m-d H:i:s', $repost['Repost']['ptime'])?></td>
	</tr>
	<tr>
		<td width="25%">
			<?php if($session->read('Auth.User.group_id')==1 || $session->read('Auth.User.id')==$repost['Repost']['user_id']):?>
			<?php echo $html->link('編', array('controller'=>'reposts', 'action'=>'edit', $repost['Repost']['id']))?>
			|
			<?php echo $html->link('刪', 
				array(
					'controller'=>'reposts', 
					'action'=>'delete', 
					$repost['Repost']['id']
				),
				array(),
				'確定要刪除嗎？'
				
			)?>
			<?php endif?>
		</td>
		<td class="post_content">
			<table>
			<tr><td><?php echo nl2br($repost['Repost']['content'])?></td></tr>
			</table>
		</td>
	</tr>
	<?php endforeach?>
	<tr><td colspan=2><?php echo $paginator->numbers()?></td></tr>
</table>
<?php endif?>